<%@ page import="com.system.dao.DoctorDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="../common.jsp" %>
<%@ taglib prefix="ui" uri="http://com.am.tag" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
	DoctorDao dao = new DoctorDao();
	Map<String,Object> map = dao.getInjectionInfo(request.getParameter("record_id"));
	pageContext.setAttribute("list", map.get("list"));
	pageContext.setAttribute("personMap", map.get("personMap"));
	pageContext.setAttribute("diagnoseMap", map.get("diagnoseMap"));
	pageContext.setAttribute("infuseMap", map.get("infuseMap"));
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'injection.jsp' starting page</title>
    <style type="text/css">
    	#receipt {
    		text-align:left;
			width:250px;
			height:100%;
			top:150px;
			left:350px;
		}
		#title {
			font-family: "微软雅黑", Verdana, Arial, Helvetica, sans-serif;
    		font-size:22px;
    		color:#242424;
    		font-weight:bold;
		}
		
		#general{
			BORDER-RIGHT: medium none;
			BORDER-TOP: medium none;
			BORDER-LEFT: medium none;
			BORDER-BOTTOM: rgb(192,192,192) 1px solid;
			text-align:center;
		}
    </style>
    
    <!-- 插入打印控件 -->
      <OBJECT  ID="jatoolsPrinter" CLASSID="CLSID:B43D3361-D075-4BE2-87FE-057188254255"
                  codebase="jatoolsPrinter.cab#version=8,6,0,0"></OBJECT>  
                  
    <script>
    	function doPrint(how) { 
   			 var myDoc = {
   			 	settings:{paperName:'a5'},   // 选择a4纸张进行打印
   			 	//settings:{orientation:2},   // 选择横向打印,1为纵向，2为横向
   			 	/*settings:{topMargin:100,
		                  leftMargin:100,
		                  bottomMargin:100,
		                  rightMargin:100},   // 设置上下左距页边距为10毫米，注意，单位是 1/10毫米
		        settings:{printer:'OKi5530'},//设置到打印机 'OKi5530'
		        */
        		documents: document,
        		copyrights: '杰创软件拥有版权  www.jatools.com'
   			 }; 
	   		 if (how == '打印预览...') {
	        	 jatoolsPrinter.printPreview(myDoc);} // 打印预览
	    	 else if (how == '打印...') {
	         	jatoolsPrinter.print(myDoc, false); // 打印前弹出打印设置对话框
	         	}
	    	else
	         	jatoolsPrinter.print(myDoc, false); // 不弹出对话框打印
		}
    	
    	function addPrivateDrug()
    	{
    		var param = $("#private_drug").html();
    		openDailog("view1","${path}/jsp/doctor/addotherInjection.jsp",450,200,"自带注射液",false,true,param,function(dlg){
				dlg.getIFrame().doSave();
			});
    	}
    	
    	function doSave()
    	{
    		doPrint('打印...');
   			var map = Form.formToBean("winForm");
	 		map.record_id = "${param.record_id}";
	 		map.private_drug = $("#private_drug").html();
	 		ajax.remoteCall("com.system.dao.DoctorDao:injection",[map],function(reply){
	 			var result = reply.getResult();
	 			alert(result.value);
	 			if(result.type == "success")
	 			{
	 				 Dialog.getInstance("view").close();
	 			}
	 		});
	 		/* $("#surePrint").click(); */
	 	}
    	
    	function addOtherDrug(param)
    	{
    		$("#private_drug").html(param);
    	}
    </script>             
  </head>
  
  <body style="overflow-x: hidden;">
  	  <form id="winForm">
		  <input type="hidden" name="id" value="${infuseMap['id']}">
		  <div style="margin-left:430px;margin-top:10px;">
		  	<input type="button" style="background:url(${path }/images/common/netvibes.png); width:64px;height:64;border:0;margin-right:10px" onclick="addPrivateDrug()"/>
		  	<%-- <ui:Permission value="doctor_infuse_print">
		  		<input type="button" id="surePrint" style="background:url(${path }/images/common/hp_printer.png); width:64px;height:64;border:0" onclick="doPrint('打印...')">
		  	</ui:Permission> --%>
		  </div>
		  <div id="page1">
		    <table id="receipt" cellSpacing="0" cellPadding="0" border="0" >
				<tr  height="40px">
		    		<td id="title" colspan="4" valign="bottom" style="text-align:center">广东技术师范学院门诊部</td>
		    		<td>&nbsp;</td>
				</tr>
				<tr  height="10px">
		    		<td id="title" colspan="4" valign="middle" style="text-align:center">输液治疗单</td>
		    		<td>&nbsp;</td>
				</tr>
				
				<tr  height="20px">
					<td colspan="3"></td>
					<td align="left" colspan="2">
						${personMap['currentDate']}
					</td>
				</tr>
				
				<tr  height="10px">
					<td align="right" width="20%">姓名：
						${personMap['name']}
					</td>
					<td align="right" width="20%">性别：
						${personMap['sex']}
					</td>
					<td align="right" width="20%">年龄：
						${personMap['age']}
					</td>
					<td align="center" width="20%">住址：
						${personMap['address']}
					</td>
					<td align="center" width="20%">&nbsp;
					</td>
				</tr>
			
				<tr height="30px">
		    		<td colspan="5" align="left" valign="bottom">
		    			<font style="font-size:small;margin-left:10px;">疾病症状、诊断：</font>
		    		</td>
				</tr>
				<tr  height="10px">
		    		<td colspan="5" align="center" valign="middle">
						<table cellpadding="0" cellspacing="0" style="float:left;padding-left:50px">
							<c:forEach var="obj" items="${fn:split(diagnoseMap['description'],'||')}" varStatus="status">
								<c:if test="${obj != '' }">
									<tr>
										<td>${status.count}、${obj}</td>
									</tr>
								</c:if>
							</c:forEach>
						</table>
		    		</td>
				</tr>
				
				<tr height="10px">
		    		<td colspan="5" align="left" valign="middle">
		    			<font style="font-size:small;margin-left:10px;">Rp.</font>
		    		</td>
				</tr>
				<tr height="10px">
					<td colspan="5" align="center" valign="middle">
						<table id="rp_table" cellpadding="0" cellspacing="0" style="float:left;padding-left:50px">
							<c:forEach var="obj" items="${list}" varStatus="status">
								<tr>
									<td>
										${status.count}、${obj.name}&nbsp;${obj.spec}*${obj.quantity } <br/>
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sig：${obj.use_method}&nbsp;&nbsp;&nbsp;${obj.consumption}&nbsp;&nbsp;&nbsp;&nbsp;${obj.times}
									</td>
								</tr>
							</c:forEach>
							<tr><td id="private_drug">${infuseMap['private_drug']}</td></tr>
						</table>
					</td>
				</tr>
				
				<tr height="35px">
		    		<td colspan="5" align="left" valign="middle">
		    			<font style="font-size:small;margin-left:10px;">注意观察事项：</font>
		    		</td>
				</tr>
				<tr height="5px">
					<td colspan="5" align="center" valign="middle">
						<textarea name="notice" rows="5" cols="60">${infuseMap['notice']}</textarea>
					</td>
				</tr>
				
				<tr height="35px">
		    		<td colspan="5" align="left" valign="middle">
		    			<font style="font-size:small;margin-left:10px;">其它：</font>
		    		</td>
				</tr>
				<tr height="5px">
					<td colspan="5" align="center" valign="middle">
						<textarea name="other" rows="3" cols="60">${infuseMap['other']}</textarea>
					</td>
				</tr>
				
				<tr>
					<td colspan="5">
						<div>
							<font style="font-size:small;margin-left:20px">配药护士：</font>
							<input type="text" id="general" style="width:100;text-align:left"/>
							<font style="font-size:small;margin-left:10px"">医师签名：</font>
						    <input type="text" id="general" style="width:100;text-align:left" value="${personMap['user_name']}"/>
						</div>
					</td>
					<%-- <td align="center" valign="middle" colspan="3">
						<font style="font-size:small;">医师签名：</font>
						<input type="text" id="general" style="width:100;text-align:left" value="${personMap['user_name']}"/>
					</td> --%>
				</tr>
			</table>
		  </div>  	
	  </form>
  </body>
</html>
